home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / maclibunix / access.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-06  |  953 b   |  35 lines  |  [TEXT/R*ch]

  1. /* Macintosh emulation of Unix 'access()' system call.
  2.    Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
  3.  
  4.    This version ignores the mode flags; it assumes files can always
  5.    be read or written when they exist.  This is more or less true,
  6.    except on write-protected volumes and maybe in a shared file system
  7.    situation.  Note that the Finder's 'locked' bit is ignored by
  8.    the file system so you can still write such files from within
  9.    an application.
  10.    Execute permission might check the file type and return Yes
  11.    if this is APPL, but I have no use for it right now anyway,
  12.    so why bother. */
  13.  
  14. #include "macdefs.h"
  15.  
  16. int
  17. access(path, mode)
  18.     char *path;
  19.     int mode;
  20. {
  21.     FileParam pb;
  22.     char name[MAXPATH];
  23.     
  24.     strncpy(name, path, sizeof name);
  25.     pb.ioNamePtr= (StringPtr) c2pstr(name);
  26.     pb.ioVRefNum= 0;
  27.     pb.ioFVersNum= 0;
  28.     pb.ioFDirIndex= 0;
  29.     if (PBGetFInfo(&pb, FALSE) != noErr) {
  30.         errno= ENOENT;
  31.         return -1;
  32.     }
  33.     return 0;
  34. }
  35.